package com.fanshuai.config;

import com.fanshuai.service.HelloService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 定义spring boot starter
 *
 * 1 创建子项目，按spring boot规范创建
 * 2 配置application.yml配置文件
 * 3 创建属性类，相关service  属性类用@Value从配置文件读取 service为定义Bean
 * 4 创建AutoConfiguration类  使用@Configuration注解封装Bean
 * 5 在resources/META-INF/spring.factories文件中，生命本jar包包含的AutoConfiguration类
 *
 * org.springframework.boot.autoconfigure.EnableAutoConfiguration=XXXAutoConfiguration
 */
@Configuration
@ComponentScan(basePackages = {"com.fanshuai.service", "com.fanshuai.config"})
public class FanshuaiAutoConfiguration {
    @Bean
    public HelloService helloService() {
        System.out.println("init helloService");
        return new HelloService();
    }
}
